IdeaBlade.EntityModel Assembly > IdeaBlade.EntityModel Namespace > EntityListManager<T> Class : ManageList Method |
'Declaration
Public Sub ManageList( _ ByVal list As IList, _ ByVal shouldRefresh As Boolean _ )
'Usage
Dim instance As EntityListManager(Of T) Dim list As IList Dim shouldRefresh As Boolean instance.ManageList(list, shouldRefresh)
public void ManageList( IList list, bool shouldRefresh )
// Example showing how a List<T> can be managed as a live list. public void EntityListManagerSample() { DomainModelEntityManager mgr = new DomainModelEntityManager(); // Retrieve a customer and employee. var customer = mgr.Customers.FirstOrDefault(c => c.Id == 1); var employee = mgr.Employees.FirstOrDefault(e => e.Id == 1); // Load a List with customer's order summaries. var list = new List<OrderSummary>(customer.OrderSummaries); int orderCount = list.Count; // We want to watch for any new orders for this customer. // We can't "watch" the NavigationEntityProperty, so watch its FK. var prop = OrderSummary.Customer_fk_IdEntityProperty; // Set up the manager. IListManager manager = new EntityListManager<OrderSummary>(mgr, os => os.Customer == customer, // filter new[] { prop }, // watch list, // list to be managed false); // refresh now // Create a new order - the list count should increment. OrderSummary aOrder = mgr.CreateEntity<OrderSummary>(); aOrder.Employee = employee; aOrder.Customer = customer; aOrder.AddToManager(); Assert.IsTrue(list.Count == orderCount + 1); // Now delete this order - the list count should decrement. aOrder.EntityAspect.Delete(); Assert.IsTrue(list.Count == orderCount); }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2